package thermologic.onewire;

import thermologic.core.Device;

/**
 * Abstract Factory - its function is create
 * instances of DeviceDelegate. 
 * 
 * @author Mauricio Rivadeneira
 */
public abstract class DeviceDelegateFactory
{
    /**
     * Create the appropiate instance of DeviceDelegate 
     * for the especified device
     * 
     * @param device 
     * @return the DeviceDelegate instance
     */
    public static DeviceDelegate getInstance(Device device, OneWireAdapter adapter)
    {
        DeviceDelegate deviceDelegate = null;
        
        switch(device.getDeviceType())
        {
            case DATALOGGER_IBUTTON_FAMILY_21:
                deviceDelegate = new DeviceDelegateOWC21(adapter);
                break;
                
            case DATALOGGER_IBUTTON_FAMILY_41:
                deviceDelegate = new DeviceDelegateOWC41(adapter);
                break;
        }
        
        return deviceDelegate;
    }
}